<?php
defined('IN_IA') or exit('Access Denied');
global $_GPC, $_W;
$aouthkey = $_GPC['aouthkey'];
$page = $_GPC['page'];
$cate_id = $_GPC['cate_id'];
$setting = $this->baseset($_W['uniacid']);
$nbkey = $setting['nbkey'];
if ($aouthkey == $nbkey) {
	$plus = "";
	if (!empty($cate_id)) {
		$plus .= " AND CONCAT(`id`) = '{$cate_id}'";
	}
	$nowpage = $_GPC['page'];
	$pindex = max(1, intval($nowpage));
	$psize = 20;
	$list = pdo_fetchall("SELECT id,name FROM " . tablename($this->tablecateall) . " WHERE uniacid = '{$_W['uniacid']}' $plus order by displayorder desc,id desc LIMIT " . ($pindex - 1) * $psize . ',' . $psize);
	$total = pdo_fetchcolumn('SELECT COUNT(id) FROM ' . tablename($this->tablecateall) . " WHERE uniacid = '{$_W['uniacid']}' $plus ");
	if ($list) {
		exit(json_encode(array('isok' => 1, 'page' => $pindex, 'total' => $total, 'content' => $list)));
	} else {
		exit(json_encode(array('isok' => 0, 'page' => $pindex, 'total' => $total, 'content' => 'none')));
	}
} else {
	exit(json_encode(array('isok' => 'aouthkey error!')));
}